/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ViewReportForm.java
 *
 * Created on Apr 13, 2012, 10:42:18 PM
 */
package GUI;

import entities.ReportDetails;
import utilities.SimpleDateFormatter;

/**
 *
 * @author VietLH
 */
public class ViewReportForm extends javax.swing.JDialog {

    /** Creates new form ViewReportForm */
    public ViewReportForm(java.awt.Frame parent, boolean modal, ReportDetails reportDetail) {
        super(parent, modal);
        initComponents();
        this.reportDetail = new ReportDetails();
        sdf=new SimpleDateFormatter();
        this.reportDetail = reportDetail;
        setReportDetail();
        this.setVisible(true);
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        lblPatienName = new javax.swing.JLabel();
        lblAddress = new javax.swing.JLabel();
        lblTestName = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        lblPatientNameDtl = new javax.swing.JLabel();
        lblDOBDtl = new javax.swing.JLabel();
        lblTestNameDtl = new javax.swing.JLabel();
        lblTestResult = new javax.swing.JLabel();
        lblDOB = new javax.swing.JLabel();
        lblAddressDtl = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        taTestResult = new javax.swing.JTextArea();
        lblStaff = new javax.swing.JLabel();
        lblStaffDtl = new javax.swing.JLabel();
        lblDoctor = new javax.swing.JLabel();
        lblDoctorDtl = new javax.swing.JLabel();
        lblGender = new javax.swing.JLabel();
        lblGenderDtl = new javax.swing.JLabel();
        lblTestDate = new javax.swing.JLabel();
        lblTestDateDtl = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Report Details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14), java.awt.Color.blue)); // NOI18N

        lblPatienName.setText("Patient Name:");

        lblAddress.setText("Address:");

        lblTestName.setText("Test Name:");

        jButton2.setText("Close");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        lblPatientNameDtl.setText("jLabel4");

        lblDOBDtl.setText("jLabel5");

        lblTestNameDtl.setText("jLabel6");

        lblTestResult.setText("Test Result:");

        lblDOB.setText("Date of birth:");

        lblAddressDtl.setText("jLabel9");

        taTestResult.setColumns(20);
        taTestResult.setRows(5);
        jScrollPane1.setViewportView(taTestResult);

        lblStaff.setText("Staff:");

        lblStaffDtl.setText("jLabel11");

        lblDoctor.setText("Doctor:");

        lblDoctorDtl.setText("jLabel13");

        lblGender.setText("Gender:");

        lblGenderDtl.setText("jLabel2");

        lblTestDate.setText("Test Date:");

        lblTestDateDtl.setText("jLabel2");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButton2)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 319, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(lblPatienName)
                                            .addComponent(lblDOB)
                                            .addComponent(lblTestName)
                                            .addComponent(lblAddress))
                                        .addGap(62, 62, 62)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(lblAddressDtl)
                                            .addComponent(lblDOBDtl)
                                            .addComponent(lblTestNameDtl)
                                            .addComponent(lblPatientNameDtl)
                                            .addComponent(lblTestDateDtl)))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(lblStaff)
                                        .addGap(7, 7, 7)
                                        .addComponent(lblStaffDtl)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 85, Short.MAX_VALUE)
                                .addComponent(lblDoctor)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(57, 57, 57)
                                        .addComponent(lblGender))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(lblDoctorDtl)))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblGenderDtl)
                        .addGap(65, 65, 65))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblTestDate)
                        .addContainerGap(435, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblTestResult)
                        .addContainerGap(428, Short.MAX_VALUE))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblPatienName)
                    .addComponent(lblPatientNameDtl)
                    .addComponent(lblGenderDtl)
                    .addComponent(lblGender))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(lblTestNameDtl))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblDOB)
                            .addComponent(lblDOBDtl))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblAddress)
                            .addComponent(lblAddressDtl))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblTestName)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(lblTestDate)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblTestResult))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblTestDateDtl)))
                .addGap(11, 11, 11)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblStaffDtl)
                    .addComponent(lblStaff)
                    .addComponent(lblDoctor)
                    .addComponent(lblDoctorDtl))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed
    private void setReportDetail() {
        this.lblAddressDtl.setText(reportDetail.getPatientDetails().getpAddress());
        this.lblDOBDtl.setText(sdf.convertDateToString(reportDetail.getPatientDetails().getpDOB()));
        if (reportDetail.getDoctorDetails().getdFName() != null && reportDetail.getDoctorDetails().getdLName() != null) {
            this.lblDoctorDtl.setText(reportDetail.getDoctorDetails().getdFName() + " " + reportDetail.getDoctorDetails().getdLName());
        } else {
            this.lblDoctorDtl.setText("-----");
        }
        this.lblPatientNameDtl.setText(reportDetail.getPatientDetails().getpFName() + " " + reportDetail.getPatientDetails().getpLName());
        if (reportDetail.getStaffDetail().getStaffFName() != null && reportDetail.getStaffDetail().getStaffLName() != null) {
            this.lblStaffDtl.setText(reportDetail.getStaffDetail().getStaffFName() + " " + reportDetail.getStaffDetail().getStaffLName());
        } else {
            this.lblStaffDtl.setText("------");
        }
        this.lblTestNameDtl.setText(reportDetail.getTest().getTestName());
        this.taTestResult.setText(reportDetail.getReport());
        this.taTestResult.setEditable(false);
        this.lblTestDateDtl.setText(sdf.convertDateToString(reportDetail.getTestDate()));
        if (reportDetail.getPatientDetails().ispGender()) {
            this.lblGenderDtl.setText("Male");
        } else {
            this.lblGenderDtl.setText("Female");
        }
    }
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(ViewReportForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(ViewReportForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(ViewReportForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(ViewReportForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the dialog */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                ViewReportForm dialog = new ViewReportForm(new javax.swing.JFrame(), true);
//                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
//
//                    @Override
//                    public void windowClosing(java.awt.event.WindowEvent e) {
//                        System.exit(0);
//                    }
//                });
//                dialog.setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblAddress;
    private javax.swing.JLabel lblAddressDtl;
    private javax.swing.JLabel lblDOB;
    private javax.swing.JLabel lblDOBDtl;
    private javax.swing.JLabel lblDoctor;
    private javax.swing.JLabel lblDoctorDtl;
    private javax.swing.JLabel lblGender;
    private javax.swing.JLabel lblGenderDtl;
    private javax.swing.JLabel lblPatienName;
    private javax.swing.JLabel lblPatientNameDtl;
    private javax.swing.JLabel lblStaff;
    private javax.swing.JLabel lblStaffDtl;
    private javax.swing.JLabel lblTestDate;
    private javax.swing.JLabel lblTestDateDtl;
    private javax.swing.JLabel lblTestName;
    private javax.swing.JLabel lblTestNameDtl;
    private javax.swing.JLabel lblTestResult;
    private javax.swing.JTextArea taTestResult;
    // End of variables declaration//GEN-END:variables
    private ReportDetails reportDetail;
    private SimpleDateFormatter sdf;
}
